<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>上传记录</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="https://s4.zstatic.net/ajax/libs/layui/2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../css/public.css" media="all">
    <script src="../js/common.js" charset="utf-8"></script>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <fieldset class="table-search-fieldset">
            <legend>搜索信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="" lay-filter="data-search">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">文件链接</label>
                            <div class="layui-input-inline">
                                <input type="text" name="fileurl" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">用户UID</label>
                            <div class="layui-input-inline">
                                <input type="text" name="uid" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">上传IP</label>
                            <div class="layui-input-inline">
                                <input type="text" name="ip" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary" lay-submit
                                    lay-filter="data-search-btn"><i class="layui-icon layui-icon-search"></i> 搜 索
                            </button>
                            <button type="submit" class="layui-btn layui-btn-primary" lay-submit
                                    lay-filter="data-refresh-btn"><i class="layui-icon layui-icon-refresh"></i> 重 置
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>

        <script type="text/html" id="toolbarDemo">
            <div class="layui-btn-container">

            </div>
        </script>

        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

        <script type="text/html" id="currentTableBar">
            <a class="layui-btn layui-btn-normal layui-btn-xs data-count-open" lay-event="open">查看</a>
        </script>

        <script type="text/html" id="uidColumn">
            <a href="javascript:;" layuimini-content-href="page/user.html?uid={{d.uid}}" data-title="用户管理">{{d.uid}}</a>
        </script>

        <a style="display: none;" href="" id="vurl" rel="noreferrer" target="_blank"></a>

    </div>
</div>
<script src="https://s4.zstatic.net/ajax/libs/layui/2.6.3/layui.js" charset="utf-8"></script>
<script src="../js/lay-config.js?v=2.0.0" charset="utf-8"></script>
<script src="../js/api.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'table', 'miniTab'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            miniTab = layui.miniTab;

        miniTab.listen();

        table.render({
            elem: '#currentTableId',
            url: '/admin/comment/uploadlog',
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [[
                {field: 'id', width: 80, title: 'ID', sort: true, fixed: 'left'},
                {field: 'uid', width: 80, title: 'UID', align: 'center', templet: "#uidColumn"},
                {field: 'type', width: 80, title: '类型', align: 'center'},
                {field: 'source', width: 100, title: '来源', align: 'center'},
                {field: 'filename', width: 200, title: '文件名称'},
                {field: 'fileurl', width: 300, title: '文件链接'},
                {field: 'ip', width: 150, title: '上传IP'},
                {field: 'addtime', width: 200, title: '上传时间', align: 'center'},
                {title: '操作', width: 120, toolbar: '#currentTableBar', align: "center", fixed: 'right'}
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 15,
            page: true,
            skin: 'line',
            response: parse_table.response,
            parseData: parse_table.parseData
        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: data.field
            }, 'data');

            return false;
        });

        // 监听重置操作
        form.on('submit(data-refresh-btn)', function (data) {
            data.field.fileurl = '';
            data.field.uid = '';
            data.field.ip = '';
            form.val('data-search', data.field)
            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: data.field
            }, 'data');

            return false;
        });

        table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'open') {
                $("#vurl").attr("href",data.fileurl);
				document.getElementById("vurl").click();
            }
        });

    });
</script>
</body>
</html>